
package shapes;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Panel;

public class shapespanel extends Panel{
    Shapes sh;
    public shapespanel(Shapes s)
      {
          super();
          setSize(400,400);
          setBackground(Color.white);
          sh=s;
      }
       public void paint(Graphics g2)
       {
           Graphics2D g = (Graphics2D) g2;
            int i=1;
            point2d p;
           
          while(sh.s[i] != null)
          {
              String type=sh.s[i].getType();
              switch(type)
              {
                  case "Circle":
                      circle c= (circle)sh.s[i];
                      p=c.getCentre();
                      g.setStroke(new BasicStroke(c.getBorderWidth()));
                      g.setColor(c.getBorderColor());
                      g.drawOval((int) p.getX(), (int) p.getY(), (int) (c.getRad()*2),(int) (c.getRad()*2) );
                      g.setColor(c.getFillColor());
                      g.fillOval((int) p.getX(), (int) p.getY(), (int) (c.getRad()*2),(int) (c.getRad()*2) );
                      break;
                  case "Square":
                      square sq=(square)sh.s[i];
                      p=sq.getTopLeft();
                      g.setStroke(new BasicStroke(sq.getBorderWidth()));
                      g.setColor(sq.getBorderColor());
                      g.drawRect((int) p.getX(), (int) p.getY(),  (int) sq.getLn(), (int) sq.getLn());
                      g.setColor(sq.getFillColor());
                      g.fillRect((int) p.getX(), (int) p.getY(),  (int) sq.getLn(), (int) sq.getLn());
                      break;
                  case "Rectangle":
                      rectangle r= (rectangle)sh.s[i];
                      p=r.getTopLeft();
                      g.setStroke(new BasicStroke(r.getBorderWidth()));
                      g.setColor(r.getBorderColor());
                      g.drawRect((int) p.getX(), (int) p.getY(), (int) r.getWid(), (int) r.getLn());
                      g.setColor(r.getFillColor());
                      g.fillRect((int) p.getX(), (int) p.getY(), (int) r.getWid(), (int) r.getLn());
                      break;
                  default :
                      
                      g.drawLine(10,10,150,150);
              }
              i++;
          }
      }
}
